package com.lanswon.qzsmk.controller.cardManageController;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.xmlbeans.impl.xb.xsdschema.Public;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lanswon.qzsmk.exception.ApplicationException;
import com.lanswon.qzsmk.model.CardData;
import com.lanswon.qzsmk.service.cardManageService.SellCardService;
import com.lanswon.qzsmk.vo.SellCardVo;
import com.lanswon.qzsmk.vo.VoucherVo;

/**
 * 售卡Controller
 * @author guyw
 *
 */
@Controller
@RequestMapping(value="/sellCard")
public class CardSellController  {
	
	
	@Autowired
	SellCardService scs;
	
	/**
	 * 链接售卡页面
	 * @return
	 */
	@RequiresPermissions("sellCard:index")
	@RequestMapping(value="/goSellCard",name="售卡,sellCard:index",method={RequestMethod.GET,RequestMethod.POST})
	public String goSellCard(){
		return "SellCard";
	}
	
	/**
	 * 提交不记名售卡
	 * @param scv
	 * @return
	 * @throws ApplicationException 
	 */
	@RequiresPermissions("sellCard:commitSellCard")
	@RequestMapping(value="/commitSellCard",name="售卡提交,sellCard:commitSellCard",method=RequestMethod.POST)
	@ResponseBody
	public  Map<String, Object> commitSellCard(SellCardVo scv,HttpServletRequest request) throws ApplicationException{
		VoucherVo vv=scs.commitSingleSellCardInfo_Anonymous(scv);
		System.out.println(vv);
		Map<String, Object> map=new HashMap<>();
		//map.put("statusCode", "200");
		//map.put("message", "提交成功");
		//map.put("callbackType", "forward");
		//map.put("forwardUrl", "sellCard/goSellCard");//post请求
		request.getSession().setAttribute("vo", vv);
		request.getSession().setAttribute("type", "sellCard");
		map.put("max", "true");
        map.put("title", "售卡凭证");
        map.put("rel", "sellCard");
        map.put("statusCode", "200");
        map.put("url", "printCredentials/toHairpinPdfView");
        
        //20181206 hgl 增加以下3行
        map.put("jumpToTile", "售卡");
        map.put("jumpToTabid", "getCardSingle");
        map.put("jumpToUrl", "sellCard/goSellCard");
		return map;
	
	}
}
